#ifndef __SETTING_H
#define __SETTING_H

#include <stdio.h>
#include "setting_structs.h"
#include "comm_interface.h"
#include "commands.h"
#include "lpc17xx.h"

struct_settings settings;

#define SETTINGS_START_ADDRESS    2048

void settings_update_to_computer(uint8_t *data, uint16_t offset, uint8_t length);
void settings_update_from_computer(uint8_t *data, uint16_t offset, uint8_t length);

void settings_save_to_eeprom(void);
void settings_load_from_eeprom(void);

/********** START SET RADIO SETTINGS **********/
void settings_set_radio_model(uint8_t value);
void settings_set_cat_interface_enabled(uint8_t value);
void settings_set_cat_baudrate(uint32_t value);
void settings_set_cat_stopbits(uint8_t value);
void settings_set_cat_parity(uint8_t value);
void settings_set_cat_icom_civ(uint8_t value);
void settings_set_cat_flow_control(uint8_t value);
void settings_set_cat_jumper_cts_rts(uint8_t value);
void settings_set_cat_retrieve_type(uint8_t value);
void settings_set_cat_poll_rate(uint8_t value);
/********** END SET RADIO SETTINGS **********/

/********** START GET RADIO SETTINGS **********/
uint8_t settings_get_radio_model(void);
uint8_t settings_get_cat_interface_enabled(void);
uint32_t settings_get_cat_baudrate(void);
uint8_t settings_get_cat_stopbits(void);
uint8_t settings_get_cat_parity(void);
uint8_t settings_get_cat_icom_civ(void);
uint8_t settings_get_cat_flow_control(void);
uint8_t settings_get_cat_jumper_cts_rts(void);
uint8_t settings_get_cat_retrieve_type(void);
uint8_t settings_get_cat_poll_rate(void);
/********** END GET RADIO SETTINGS **********/

/********** START SET PTT SETTINGS **********/
void settings_set_ptt_input_enabled(uint8_t value);
void settings_set_ptt_input_invert(uint8_t value);
void settings_set_ptt_radio_pre_delay(uint8_t value);  //in 10th of ms, so 10 means 100ms
void settings_set_ptt_radio_post_delay(uint8_t value);
void settings_set_ptt_amp_pre_delay(uint8_t value);
void settings_set_ptt_amp_post_delay(uint8_t value);
void settings_set_ptt_inhibit_pre_delay(uint8_t value);
void settings_set_ptt_inhibit_post_delay(uint8_t value);
void settings_set_ptt_antenna_pre_delay(uint8_t value);
void settings_set_ptt_antenna_post_delay(uint8_t value);
void settings_set_radio_digital_ptt(uint8_t value);
void settings_set_radio_cw_ptt(uint8_t value);
void settings_set_radio_phone_ptt(uint8_t value);
void settings_set_amplifier_enabled(uint8_t value);
void settings_set_inhibit_enabled(uint8_t value);
/********** END SET PTT SETTINGS **********/

/********** START GET PTT SETTINGS **********/
uint8_t settings_get_ptt_input_enabled(void);
uint8_t settings_get_ptt_input_invert(void);
uint8_t settings_get_ptt_radio_pre_delay(void);  //in 10th of ms, so 10 means 100ms
uint8_t settings_get_ptt_radio_post_delay(void);
uint8_t settings_get_ptt_amp_pre_delay(void);
uint8_t settings_get_ptt_amp_post_delay(void);
uint8_t settings_get_ptt_inhibit_pre_delay(void);
uint8_t settings_get_ptt_inhibit_post_delay(void);
uint8_t settings_get_ptt_antenna_pre_delay(void);
uint8_t settings_get_ptt_antenna_post_delay(void);
uint8_t settings_get_radio_digital_ptt(void);
uint8_t settings_get_radio_cw_ptt(void);
uint8_t settings_get_radio_phone_ptt(void);
uint8_t settings_get_amplifier_enabled(void);
uint8_t settings_get_inhibit_enabled(void);
/********** END GET PTT SETTINGS **********/

/********** START GET AUDIO SETTINGS **********/
void settings_set_af_input_source_cw(uint8_t type, uint8_t state);
void settings_set_af_input_source_phone(uint8_t type, uint8_t state);
void settings_set_af_input_source_digital(uint8_t type, uint8_t state);
void settings_set_mic_path(uint8_t type, uint8_t state);
void settings_set_computer_generated_path_phone(uint8_t type, uint8_t state);
void settings_set_computer_generated_path_digital(uint8_t type, uint8_t state);
void settings_set_mic_mute(uint8_t type, uint8_t state);
void settings_set_mic_preamp(uint8_t type, uint8_t state);
void settings_set_line_out_mute_phone(uint8_t type, uint8_t state);
void settings_set_line_out_mute_digital(uint8_t type, uint8_t state);
/********** END GET AUDIO SETTINGS **********/

/********** START GET AUDIO SETTINGS **********/
uint8_t settings_get_af_input_source_cw(uint8_t type);
uint8_t settings_get_af_input_source_phone(uint8_t type);
uint8_t settings_get_af_input_source_digital(uint8_t type);
uint8_t settings_get_mic_path(uint8_t type);
uint8_t settings_get_computer_generated_path_phone(uint8_t type);
uint8_t settings_get_computer_generated_path_digital(uint8_t type);
uint8_t settings_get_mic_mute(uint8_t type);
uint8_t settings_get_mic_preamp(uint8_t type);
uint8_t settings_get_line_out_mute_phone(uint8_t type);
uint8_t settings_get_line_out_mute_digital(uint8_t type);
/********** END GET AUDIO SETTINGS **********/

#define SETTINGS_UPDATE_TO_COMPUTER(x) settings_update_to_computer((uint8_t *)&x, (uint16_t)((uint32_t)&x - (uint32_t)&settings), sizeof(x))

#endif /* end __SETTING_H */
/****************************************************************************
** End Of File
*****************************************************************************/
